using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_SuaNhanvien : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_manv.Text = id.ToString();

            tbNhanvien nhanvien = tbNhanvienBUS.GetByID(id);
            txt_tennv.Text = nhanvien.Tennv.ToString();
            txt_gioitinh.Text = nhanvien.Gioitinh.ToString();
            txt_tendangnhap.Text = nhanvien.Tendangnhap.ToString();
            txt_matkhau.Text = nhanvien.Matkhau.ToString();
            txt_email.Text = nhanvien.Email.ToString();
            txt_dienthoai.Text = nhanvien.Sodthoai.ToString();
        }
        catch
        {
            Response.Redirect("~/Admin/DanhsachNhanvien.aspx");
        }
    }
    protected void btn_sua_Click(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["iD"].ToString());
            tbNhanvien nhanvien = tbNhanvienBUS.GetByID(id);

            nhanvien.Tennv = txt_tennv.Text;
            nhanvien.Tendangnhap= txt_tendangnhap.Text;
            nhanvien.Matkhau = txt_matkhau.Text;
            nhanvien.Email = txt_email.Text;
            nhanvien.Sodthoai = txt_dienthoai.Text;

            tbNhanvienBUS.Update(nhanvien);
        }
        catch
        {
        }
        Response.Redirect("~/Admin/DanhSachNhanvien.aspx");
        Response.Redirect(Request.RawUrl);
    }
}
